package com.edu.exam.enums.quality;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 安全级别枚举
 */
@Getter
@AllArgsConstructor
public enum SafetyLevel {
    EXCELLENT("EXCELLENT", "优秀"),
    GOOD("GOOD", "良好"),
    SATISFACTORY("SATISFACTORY", "合格"),
    NEEDS_IMPROVEMENT("NEEDS_IMPROVEMENT", "需改进"),
    POOR("POOR", "较差"),
    CRITICAL("CRITICAL", "严重不足"),
    SAFE("SAFE", "安全"),
    UNSAFE("UNSAFE", "不安全");

    private final String code;
    private final String description;

    public static SafetyLevel fromCode(String code) {
        for (SafetyLevel level : values()) {
            if (level.getCode().equals(code)) {
                return level;
            }
        }
        return SATISFACTORY; // 默认返回合格
    }
}